/*************************************************************************
 *  Copyright © 2023-2030 FXB CO.,LTD. All rights reserved.
 *------------------------------------------------------------------------
 *  公司：DefaultCompany
 *  项目：UPMProject
 *  文件：CustomEditorComponent.cs
 *  作者：Administrator
 *  日期：2025/7/25 14:22:19
 *  功能：Nothing
*************************************************************************/

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace SVNPackageManager.Editor
{
    public class CustomEditorComponent
    {
        public static bool DrawLinkButton(string content)
        {
            bool isClicked = false;

            // 创建一个GUIStyle来模拟链接样式
            GUIStyle linkStyle = new GUIStyle(GUI.skin.label);
            linkStyle.normal.textColor = new Color(0x00 / 255f, 0x78 / 255f, 0xDA / 255f, 1); // 蓝色
            //linkStyle.stretchWidth = true;

            // 使用GUILayout.Label并检查点击
            Rect rect = GUILayoutUtility.GetRect(new GUIContent(content), linkStyle);
            if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
            {
                isClicked = true;

                Event.current.Use();
            }

            GUI.Label(rect, content, linkStyle);
            Handles.color = linkStyle.normal.textColor;
            Handles.DrawAAPolyLine(1.1f, new Vector2(rect.x, rect.y + rect.height), new Vector2(rect.x + rect.width, rect.y + rect.height));

            return isClicked;
        }
    }
}


